
//704.二分查找
class Solution {
    int islower_bound(vector<int> nums,int target)
    {
        int left=-1;
        int right=nums.size();
        while(left+1<right)
        {
            int mid=left+(right-left)/2;
            if(nums[mid]<target) left=mid;
            else right=mid;
        }
        return right;
    }

public:
    int search(vector<int>& nums, int target) {
        //在第一个大于等于target的位置
        int n=nums.size();
        int pos=islower_bound(nums,target);
        if(pos==n) return -1;

        return nums[pos]==target?pos:-1;
    }
};